Raj26-June-2025
How to Master SQL from Basic to Advance in 45 Days
Overview:
This comprehensive 45-day SQL roadmap is designed to take you from beginner to advanced level with real-world problem-solving, interview preparation, and project-based learning. Whether you're aiming for a role in data analytics, engineering, or backend development, this structured plan ensures mastery of SQL concepts with hands-on practice and curated interview questions.
What’s Inside:
-
Week-by-Week Learning Path: From
SELECT
basics to advancedWindow Functions
andCTEs
. -
21+ Interview Questions Per Week: Covering theoretical and practical scenarios frequently asked in top tech interviews.
-
Sample Problems & Projects: Real-world use cases to build proficiency and confidence.
-
Optimization Techniques: Includes query tuning, indexing, and execution plan analysis.
-
Capstone Projects: Dashboard creation, user churn analysis, and sales insights.
Perfect for self-learners, job seekers, and students preparing for FAANG-level interviews or aspiring to become data professionals.
How to Master SQL from Basic to Advance in 45 Days
A Step-by-Step Roadmap with Interview Questions, Tips, and Sample Problems
Introduction
Þ SQL (Structured Query Language) is the cornerstone of data-driven decision-making. Whether you're building dashboards, writing ETL pipelines, or preparing for a data role interview, mastering SQL is essential.
Þ This guide outlines a 45-day intelligent roadmap to help you progress from beginner to advanced SQL fluency, along with interview questions and sample problems at every step.
45-Day SQL Roadmap:
Week |
Focus Area |
Key Concepts |
Deliverables |
1 |
SQL Basics |
SELECT, WHERE, ORDER BY, LIMIT, DISTINCT |
Solve 15 basic SELECT queries |
2 |
Joins & Relationships |
INNER JOIN, LEFT/RIGHT JOIN, SELF JOIN |
Join-based exercises and mini-ERD project |
3 |
Aggregations & Grouping |
GROUP BY, HAVING, COUNT, SUM, AVG |
Aggregation-based queries, sales report |
4 |
Subqueries & Set Ops |
Subqueries, IN/EXISTS, UNION, INTERSECT |
Write layered queries and nested logic |
5 |
Advanced SQL |
CTEs, Window Functions, CASE, RANK() |
Solve 10 FAANG-style SQL questions |
6 |
Optimization & Projects |
Indexing, EXPLAIN, Dashboards, Mock Interviews |
Build a SQL project + mock test rounds |
Important
Interview Questions:
Week 1: SQL Basics
- What is SQL?
- What is the difference between WHERE and HAVING?
- What does SELECT DISTINCT do?
- How does LIMIT work?
- What are data types in SQL?
- Difference between NULL and 0?
- What is the default sorting in ORDER BY?
- How to fetch top N records?
- What’s the difference between = and LIKE?
- What are wildcards?
- Explain BETWEEN and IN?
- What is a primary key?
- How does SQL handle case sensitivity?
- What is an alias in SQL?
- How to concatenate two columns?
- What is IS NULL vs = NULL?
- Can you use WHERE with aggregate functions?
- How do you write comments in SQL?
- How to avoid duplicates in output?
- What is a Cartesian Product?
- What is the use of AS keyword?
Week 2: Joins
- What is a JOIN?
- Difference between INNER and LEFT JOIN
- What is a RIGHT JOIN?
- When do we use FULL OUTER JOIN?
- What is a SELF JOIN?
- What is a CROSS JOIN?
- How does JOIN work internally?
- Can we JOIN more than 2 tables?
- What is a composite JOIN condition?
- Difference between JOIN and UNION
- What is a foreign key?
- Use case of joining tables without a common key?
- How to write JOINs using aliases?
- What happens if JOIN condition is missing?
- How does SQL optimize JOINs?
- Best practices for writing JOINs?
- Difference between ON and USING
- How to handle NULLs in JOINs?
- What is a semi-join?
- What is an anti-join?
- Explain a scenario using multiple JOINs?
Week 3: Aggregations & Grouping
- What is GROUP BY?
- Why do we use HAVING?
- Difference between WHERE and HAVING
- How do aggregate functions work?
- What is the use of COUNT(*)?
- How to get AVG salary per department?
- What happens if we skip GROUP BY in aggregate query?
- What is the use of MIN() and MAX()?
- How to group by multiple columns?
- What is roll-up and cube (if supported)?
- Can we use aggregate inside WHERE?
- How do you calculate percentage from aggregate?
- Real-time use cases of aggregation
- How to filter group-based conditions?
- Difference between COUNT and COUNT(DISTINCT)
- How to calculate running totals?
- What is the purpose of HAVING 1=1?
- How to sort groups based on aggregation?
- How does GROUP BY affect performance?
- Use GROUP BY with JOIN
- What are the limitations of GROUP BY?
Week 4: Subqueries and Set Operations
- What is a subquery?
- Where can subqueries be used?
- Difference between correlated and non-correlated subqueries
- What is IN, EXISTS, and NOT EXISTS?
- Use case of subquery in SELECT
- Subquery vs JOIN
- Performance differences between JOIN and subquery
- What is ANY, SOME, ALL?
- Nesting levels allowed in your DBMS?
- What is a derived table?
- Can we update using subqueries?
- How does subquery work inside WHERE?
- Difference between UNION and UNION ALL
- When to use INTERSECT?
- What is the use of EXCEPT?
- Set operations syntax across DBMS
- Order of execution: subqueries vs outer query
- Handling NULL in subqueries
- Top N per group using subquery
- How to rewrite subquery as JOIN?
- Pitfalls in using deeply nested subqueries
Week 5: Advanced SQL
- What is a CTE?
- Difference between CTE and Subquery
- What are Window Functions?
- Syntax for RANK(), DENSE_RANK(), ROW_NUMBER()
- Use case for LAG() and LEAD()
- Real-time application of window functions
- How does PARTITION BY work?
- What is ORDER BY inside OVER()?
- Difference between ROW_NUMBER() and RANK()
- What is a CASE expression?
- Nested CASE usage
- What is COALESCE()?
- How to pivot/unpivot data?
- Explain recursive CTE
- How to calculate moving average?
- What is NULLIF()?
- Difference between NVL() and ISNULL()
- How to handle duplicates with window functions?
- Window function performance implications
- Ranking top-N per category
- Use of FILTER clause in aggregation (if supported)
Week 6: Optimization & Projects
- What is indexing in SQL?
- How does indexing speed up queries?
- What is a clustered vs non-clustered index?
- How to view the execution plan?
- What is EXPLAIN keyword?
- How to identify slow SQL queries?
- What is query cost?
- How to avoid full table scans?
- What is normalization?
- What are the normal forms?
- What is denormalization?
- Query optimization tips
- What is a materialized view?
- Temporary tables vs CTE
- How to use EXISTS to improve performance?
- What is the difference between logical and physical plans?
- Real-time example of indexing benefit
- Pitfalls of over-indexing
- How to tune GROUP BY + JOIN query?
- Project scenario: user churn report
- Project scenario: sales dashboard
Sample Problems for Each Week
Week 1: SQL Basics
- Problem 1: Select names of all employees from the employee table.
- Problem 2: Retrieve products priced above $100 sorted in descending order.
- Problem 3: Find unique cities from a customer table.
- Hint: Practice SELECT, WHERE, DISTINCT, ORDER BY, and LIMIT
Week 2: Joins & Relationships
- Problem 1: List customers and their orders using INNER JOIN.
- Problem 2: Show all customers with or without orders using LEFT JOIN.
- Problem 3: Retrieve employee-manager pairs using SELF JOIN.
- Hint: Understand join conditions and relational schema design.
Week 3: Aggregations & Grouping
- Problem 1: Find total sales per region.
- Problem 2: Show customers who placed more than 5 orders.
- Problem 3: Average product price per category.
- Hint: Use GROUP BY, HAVING, COUNT, SUM, AVG.
Week 4: Subqueries and Set Operations
- Problem 1: Select customers who didn’t place any orders.
- Problem 2: Find products that are cheaper than the average price.
- Problem 3: List common employee IDs from two departments using INTERSECT.
- Hint: Use subqueries inside SELECT and WHERE, and practice UNION/EXCEPT.
Week 5: Advanced SQL
- Problem 1: Rank employees by salary within each department.
- Problem 2: Display each customer’s previous order date using LAG().
- Problem 3: Create a CTE to calculate total sales and use in main query.
- Hint: Practice CTE, window functions (OVER), and CASE expressions.
Week 6: Optimization & Projects
- Problem 1: Optimize a slow query that joins large tables and groups by.
- Problem 2: Create an EXPLAIN plan for a sales report query.
- Problem 3: Build a dashboard-ready query that shows weekly revenue by category.
- Hint: Focus on EXPLAIN, indexing, and efficient SQL design.